<?php
//$this->menu = array(
//    array('label' => Util::t('Create Customer Group', array(), 'Label'), 'url' => array('//customer/group/create')),
//    array('label' => Util::t('Create Customer', array(), 'Label'), 'url' => array('create')),
//);
$this->mainTitle = Util::t(UserModule::t("Manage Users"), array(), 'Label');
?>
<h1><?php echo $this->mainTitle; ?></h1>

<?php echo CHtml::link(Util::t('Form Search'), '#', array('class' => 'search-button')); ?>
<div class="search-form" style="">
    
    <?php
    $this->renderPartial('_search', array(
        'model' => $model,
    ));
    ?>    
</div><!-- search-form -->

<script type="text/javascript" src="<?php echo Yii::app()->baseUrl . '/script' ?>" ></script>
<?php
$this->menu = array(
    array('label' => UserModule::t('Manage User'), 'url' => array('admin')),
    array('label' => UserModule::t('Manage Profile Field'), 'url' => array('profileField/admin')),
    array('label' => UserModule::t('Create User'), 'url' => array('create')),
);
?>

<?php
$pageSize = Yii::app()->user->getState('pageSize');
$this->widget('zii.widgets.grid.CGridView', array(
    'id' => 'user-grid',
    'dataProvider' => $dataProvider,
    'selectionChanged' => 'function(id){document.location.href="' . $this->createUrl('/user/admin/update/id/') . '/"+$.fn.yiiGridView.getSelection(id)}',
    'columns' => array(
        array(
            'name' => 'id',
            'type' => 'raw',
            'value' => 'CHtml::link(CHtml::encode($data->id),array("admin/update","id"=>$data->id))',
            'htmlOptions' => array(
                'align' => 'center',
                'title' => Util::t('Update')
            )
        ),
        array(
            'name' => 'username',
            'type' => 'raw',
            'value' => 'CHtml::link(CHtml::encode($data->username),array("admin/view","id"=>$data->id))',
            'htmlOptions' => array(
                'align' => 'center',
                'title' => Util::t('View')
            )
        ),
        array(
            'name' => 'email',
            'type' => 'raw',
            'value' => 'CHtml::link(CHtml::encode($data->email), "mailto:".$data->email)',
            'htmlOptions' => array(
                'align' => 'center',
                'title' => Util::t('Email')
            )
        ),
        array(
            'name' => 'createtime',
            'value' => 'date("d.m.Y H:i:s",$data->createtime)',
        ),
        array(
            'name' => 'lastvisit',
            'value' => '(($data->lastvisit)?date("d.m.Y H:i:s",$data->lastvisit):UserModule::t("Not visited"))',
        ),
        array(
            'name' => 'status',
            'value' => 'User::itemAlias("UserStatus",$data->status)',
            'htmlOptions' => array(
                'align' => 'center',
            )
        ),
        array(
            'name' => 'superuser',
            'value' => '$data->role->itemname',   
            'footer' => 'Items: ' . CHtml::dropDownList('pageSize', $pageSize, array(
                $pageSize => $pageSize,
                20 => 20,
                50 => 50,
                100 => 100), array(
                // change 'user-grid' to the actual id of your grid!!
                'onchange' => "$.fn.yiiGridView.update('user-grid',{ data:{pageSize: $(this).val() }})",
            )),  
        ),
    ),
    
));
?>
